Skip to content

container-export: Handle metacopy=off overlay setups#2097

Merged
jeckersb merged 1 commit intobootc-dev:mainfrom
cgwalters:metacopy
Mar 27, 2026
Merged

container-export: Handle metacopy=off overlay setups#2097
jeckersb merged 1 commit intobootc-dev:mainfrom
cgwalters:metacopy

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

This fixes a bug in container export on overlayfs setups with metacopy=off (a common setup). In that scenario we will see a single mountpoint, but different device+inode.

Change hardlink tracking to account for device+inode.

Assisted-by: OpenCode (Claude Opus 4)

This fixes a bug in `container export` on overlayfs setups with
`metacopy=off` (a common setup). In that scenario we will see
a single mountpoint, but different device+inode.

Change hardlink tracking to account for device+inode.

Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>
@bootc-bot bootc-bot bot requested a review from jmarrero March 26, 2026 16:37
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the hardlink tracking logic in container_export.rs to use a combination of device ID and inode number as the key, rather than just the inode. This change accommodates overlay filesystems where device numbers may differ between directories and files. Additionally, the explicit check for an expected device ID has been removed. I have no feedback to provide.

let filename_path = Path::new(filename);
let metadata = dir.metadata(filename_path)?;

// Skip files on different devices (e.g., bind mounts in containers like /etc/hosts).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that now we would start including the bind-mounted /etc/hosts when we export?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it does.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As documented, this expects the image as a separate mount point:

podman run --rm \
    --mount=type=image,source=quay.io/example/example,target=/run/target \
    quay.io/example/example \
    bootc container export --kernel-in-boot /run/target > example.tar

And in that case, there won't be any container runtime injected content like /etc/hosts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(IOW I messed this up originally, the previous code was never necessary)

@jeckersb jeckersb merged commit 0018400 into bootc-dev:main Mar 27, 2026
62 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants